package com.queclink.puzzle.common;

import javax.swing.*;
import java.util.Calendar;

/**
 * @author jim.li
 * @email jim.li@queclink.com
 * @date 2022-06-16 10:36:00
 */
public class PuzzleJFrame extends JFrame {


    public static void createAndShowGUI(){
        Calendar cal = Calendar.getInstance();
        Place.MONTH = cal.get(Calendar.MONTH);
        Place.DAY = cal.get(Calendar.DAY_OF_MONTH);
        Place.WEEK = cal.get(Calendar.DAY_OF_WEEK);
        // 创建 JFrame 实例
        JFrame puzzleJFrame = new JFrame("时间拼图");
        // Setting the width and height of frame
        puzzleJFrame.setBounds(100, 100, 500, 500);
        puzzleJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        JPanel panel = new JPanel();
        panel.setLayout(null);
        panel.setBounds(100, 100, 300, 300);
        Place place = new Place();
        place.placeComponents(panel);
        puzzleJFrame.add(panel);

        // 设置界面可见
        puzzleJFrame.setVisible(true);
        puzzleJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void openNewJFrame() {
        // 创建 JFrame 实例
        JFrame puzzleJFrame = new JFrame("解法");
        // Setting the width and height of frame
        puzzleJFrame.setSize(900, 800);
        puzzleJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        PuzzlePanel puzzlePanel = new PuzzlePanel();
        puzzlePanel.setLayout(null);
        puzzlePanel.setBounds(0, 0, 800, 700);
        puzzleJFrame.add(puzzlePanel);

        // 设置界面可见
        puzzleJFrame.setVisible(true);
        puzzleJFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
}
